home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
C++ Toolbox 1.0
/
QuickDraw++.cp
< prev
next >
Wrap
Text File
|
1995-11-16
|
1KB
|
72 lines
/*
File: QuickDraw++.cp
Contains: C++ extensions to QuickDraw.
Version: 1.0
Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
*/
#include <LDataStream.h> // * PowerPlant
#include "QuickDraw++.h"
//
// construct a ColorSpecTable using flattened ColorTable data
//
ColorSpecTable::ColorSpecTable(LStream &inTableStream)
{
SInt16 ctSize;
// skip past ctSeed and ctFlags
inTableStream.SetMarker(sizeof(UInt32) + sizeof(UInt16), streamFrom_Marker);
// read color count
inTableStream.ReadData(&ctSize, sizeof(SInt16));
Assert_(ctSize > 0); // sanity check
mColorTable.setcount(ctSize + 1);
// read in colorspecs
ColorSpec cSpec;
mColorTable.lock();
for(long curColor = 0; curColor <= ctSize; curColor++)
{
inTableStream.ReadData(&cSpec, sizeof(ColorSpec));
mColorTable[curColor] = cSpec;
}
mColorTable.unlock();
}
//
// LookupIndexColor
// Given an index, return the corresponding color
//
Boolean
ColorSpecTable::LookupIndexedColor(long inIndex, RGBColor &outColor)
{
mColorTable.lock();
long colorCount = mColorTable.getcount();
Boolean outFound = false;
for(long curColor = 0; curColor < colorCount; curColor++)
{
if(mColorTable[curColor].value == inIndex)
{
outColor = mColorTable[curColor].rgb;
outFound = true;
break;
}
}
mColorTable.unlock();
return outFound;
}